function writeSegFile(s, onsets, offsets, hop, filename, fs, nbits)
%function writeSegFile(x);

for i=1:(length(onsets))
	nomeAux = cat(2, '..\audio\', filename(1:length(filename)-4), '_', num2str(i), '.wav'); % nome para salvar o arquivo
	wavwrite(s(onsets(i):offsets(i)), fs, nbits, nomeAux);
    wavplay([s(onsets(i):offsets(i)); zeros(44100, 1)], fs);    
%    wavplay([s(vet(i):vet(i+1)); zeros(floor(0.5*(vet(i+1)-vet(i))), 1)], fs);
end
